package com.kaaction.modules.mer.api;

import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.kaaction.common.web.BaseController;
import com.kaaction.modules.mer.entity.WeddingProcess;
import com.kaaction.modules.mer.service.WeddingProcessService;

@Controller
@RequestMapping(value = "/api/v1/weddingProcessApi")
public class WeddingProcessApiController extends BaseController{
	
	@Autowired
	WeddingProcessService weddingProcessService;
	
	/**
	 * 婚礼流程添加
	 * 
	 * @param request
	 * @param response
	 * @throws UnsupportedEncodingException
	 * @throws DocumentException
	 * @throws ParseException 
	 */
	@RequestMapping(value = "/addWeddingProcess",method = RequestMethod.POST)
	public void addWeddingProcess(HttpServletRequest request, HttpServletResponse response)
			throws UnsupportedEncodingException, DocumentException, ParseException {
		
		WeddingProcess weddingProcess = new WeddingProcess();
		
		String thirdpartyId = request.getParameter("thirdpartyId");//第三方id
		String content = request.getParameter("content");//json格式
		weddingProcess.setThirdpartyId(thirdpartyId);
		weddingProcess.setContent(content);
		weddingProcessService.insOrUpdWeddingProcess(weddingProcess);
		super.writeAjaxResponse(response,"");
	}
	
	/**
	 * 婚礼流程分享查询
	 * 
	 * @param request
	 * @param response
	 * @throws UnsupportedEncodingException
	 * @throws DocumentException
	 * @throws ParseException 
	 */
	@RequestMapping(value = "/selWeddingProcess")
	public void selWeddingProcess(HttpServletRequest request, HttpServletResponse response)
			throws UnsupportedEncodingException, DocumentException, ParseException {
		
		WeddingProcess weddingProcess = new WeddingProcess();
		
		String thirdpartyId = request.getParameter("thirdpartyId");//第三方id
		weddingProcess.setThirdpartyId(thirdpartyId);
		super.writeAjaxResponse(response,weddingProcessService.get(weddingProcess));
	}

}
